package com.bilibili.sys.utils;

import com.mysql.cj.jdbc.MysqlDataSource;
import org.apache.commons.dbutils.QueryRunner;

import javax.sql.DataSource;

/**
 * @author alpha
 * @program: BookSystem
 * @description: 操作数据库的工具类
 * @since 2024-03-24 22:30
 **/

public class MyDBUtils {
    //定义的数据源
    private static MysqlDataSource dataSource;
    static {
        //完成数据源的初始化操作
        dataSource = new MysqlDataSource();
        dataSource.setUrl("jdbc:mysql://localhost:3307/books?serverTimezone=UTC");
        dataSource.setUser("root");
        dataSource.setPassword("root");
    }
    public static QueryRunner getQueryRunner(){
        return new QueryRunner(dataSource);
    }
}
